package com.itheima.web.response;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

//
@WebServlet("/resp3")
public class ResponseDemo3 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("ResponseDemo3...");
        // 解决响应客户端中文的问题，告诉浏览器，你给它的什么内容，及编码
        resp.setContentType("text/html; charset=utf-8");
        //resp.setContentType("text/json; charset=utf-8");
        // 写字符串
        PrintWriter out = resp.getWriter();
        out.write("<html>");
        out.write("<body>");
        out.println("<H1>hello</h1>");
        out.println("<H2>张三</h2>");
        out.println("</body>");
        out.println("</html>");

    }
}
